package com.testapp.bluetoothtest08.cipher;


import com.testapp.bluetoothtest08.cipher.entity.JoinCheckStr;
import com.testapp.bluetoothtest08.cipher.entity.ScanCodeFirstRequest;
import com.testapp.bluetoothtest08.cipher.entity.ScanCodeSecondRequest;
import com.testapp.bluetoothtest08.cipher.entity.UserUpdate;
import com.testapp.bluetoothtest08.cipher.entity.user.UserPrivateData;
import com.testapp.bluetoothtest08.cipher.entity.user.UserPrivateDataStr;
import com.testapp.bluetoothtest08.cipher.entity.user.UserScanCodeData;

import java.util.List;

/**
 * 用户端
 */
public interface UserCipherService {

    /**
     * 用户注册函数
     *
     * @param Cku 私钥
     * @param Pku 公钥
     * @return [UserJoin, UserPrivateData]
     * 注册传给后端  保存缓存，等待后端返回参数
     */
    List<Object> UserJoinRequest(String Cku, String Pku);

    /**
     * 用户注册接收后端返回参数后
     *
     * @param userData
     * @param joinCheckStr
     * @return 存储本地的用户数据 需要用时可以使用 new UserPrivateData(UserPrivateDataStr)进行转换
     */
    UserPrivateDataStr UserJoinResponse(UserPrivateData userData, JoinCheckStr joinCheckStr);

    /**
     * 制定私钥长度
     *
     * @param Cku
     * @param Pku
     * @param length
     * @return
     */
    List<Object> UserJoinRequest(String Cku, String Pku, int length);

    /**
     * 用户端扫描二维码首次请求
     *
     * @param user
     * @return [UserScanCodeData userData, ScanCodeFirstRequest requestData]
     */
    List<Object> scanCodeRequestFirst(UserPrivateData user);

    /**
     * 用户扫描二维码反馈challenge请求
     *
     * @param user
     * @param userData
     * @param challenge
     * @return challenge之后的验证数据
     */
    ScanCodeSecondRequest scanCodeRequestSecond(UserPrivateData user, UserScanCodeData userData, ScanCodeFirstRequest requestData, String challenge);

    /**
     * 合并扫码请求
     * @param user
     * @param challenge
     * @return [UserScanCodeData userData, ScanCodeFirstRequest requestFirst, ScanCodeSecondRequest requestSecond]
     */
    List<Object> scanCodeRequestCombine(UserPrivateData user, String challenge);

    /**
     * 验证后修改用户本地数据
     * @param user
     * @param userData
     * @return 是否修改成功，如果ic不对说明可能并非是正确的请求
     */
    boolean changePrivateData(UserPrivateData user, UserScanCodeData userData, UserUpdate userUpdate);

    public List<Object> scanCodeRequestFirstTest(UserPrivateData user);
}
